home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / ansi / math / elefunt / randl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-18  |  641 b   |  30 lines

  1. /* -*-C-*- randl.c */
  2.  
  3. #include "elefunt.h"
  4.  
  5. /***********************************************************************
  6.  
  7. Returns pseudo  random numbers  logarithmically distributed  over
  8. (1,exp(x)).  Thus a*randl(ln(b/a)) is logarithmically distributed
  9. in (a,b).
  10.  
  11. Other subroutines required:
  12.  
  13.     exp(x) - The exponential routine.
  14.  
  15.     ran(k) - A function program returning random real
  16.         numbers uniformly distributed over (0,1).  The
  17.         argument k is a dummy.   
  18.  
  19. ***********************************************************************/
  20.  
  21. float
  22. randl(x)
  23. float x;
  24. {
  25.  
  26.     static int k = 1;
  27.  
  28.     return (exp(x * ran(k)));
  29. }
  30.